import java.util.Random;

// This extends Deck
public class HoyleDeck implements Deck {

	// Constructor of a deck to length 52
	private Card[] deck = new Card[52];

	// Constructor to show the number of cards in the deck at start of deal
	private int numLeft = deck.length;

	public HoyleDeck() {

		// Create the deck using nested FOR LOOP
		int i = 0;
		for (Card.Suit suit : Card.Suit.values()) { // Use the "values" method
													// to get all the enum types
			for (Card.FaceValue faceValue : Card.FaceValue.values()) {
				deck[i] = new Card(suit, faceValue);
				i++;
			}
		}
		// Shuffle the deck (method)
		shuffleDeck();
	}

	@Override
	public int getNumCards() {
		// TODO Auto-generated method stub
		return deck.length;
	}

	// Method to Shuffle Deck
	@Override
	public void shuffleDeck() {
		// Calls random class and creates rGen object
		Random rGen = new Random();
		// Start a FOR LOOP that starts with the number of cards
		// Then decreases it by 1 until it reaches 0
		for (int i = deck.length - 1; i > 0; i--) {
			
			// Create integer called randomNumber that randomly selects the next
			// card number from the remaining
			int randomNumber = rGen.nextInt(i--);
			
			// Move the i card out into holding tank
			Card holdMyBreath = deck[i];
			
			// Move randomNumber card into i
			deck[i] = deck[randomNumber];
			
			// Move card in holding tank into randomNumber
			deck[randomNumber] = holdMyBreath;
		}
	}

	// Method to count the number of cards left in the deck after each card
	// dealt
	@Override
	public Card deal() {
		if (numLeft > 0) {
			return deck[--numLeft];
		}
		return null;
	}

	@Override
	public int numCardsLeft() {
		return 0;
	}

	@Override
	public int numCardsDealt() {

		return 0;
	}

	// Method to shuffle player's cards
	@Override
	public void shuffle() {
		// TODO Auto-generated method stub

	}

	public Card[] getDeck() {
		return deck;
	}

	public void setDeck(Card[] deck) {
		this.deck = deck;
	}

	public int getNumLeft() {
		return numLeft;
	}

	public void setNumLeft(int numLeft) {
		this.numLeft = numLeft;
	}

}
